<include file="Common/header" />
<title>新闻资讯</title>
<!--
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
-->
<link rel="stylesheet" href="__PUBLIC__/xheditor-1.2.2/demos/common.css" type="text/css" media="screen" />
<script type="text/javascript" src="__PUBLIC__/xheditor-1.2.2/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/xheditor-1.2.2/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript" src="__PUBLIC__/h-ui/lib/jquery/1.9.1/jquery.form.js"></script>
<script>
	/**
	 * 上传图片
	 **/
	function uploadImages(){
		var load = layer.load(2);
		$("#uploadform").ajaxSubmit({
			type:'post',
			url:'../index/upload.html',
			success:function(data){
				layer.close(load);
				var data = JSON.parse(data);
				if(data.errCode/1 > 0){
					layer.msg('上传成功', {icon:1, time: 2000});
					$("#images").val(data.errMsg);
					$("#imgshow").show();
					$("#imgshow img").attr('src', "__PUBLIC__/upload/"+ data.errMsg);
				}else{
					layer.msg(data.errMsg, {icon:2, time: 2000});
				}
			},
			error:function(XmlHttpRequest,textStatus,errorThrown){
				
			}
		});
	}
</script>
</head>
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 公众号管理
	<span class="c-gray en">&gt;</span> 新闻资讯
	<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="pd-20">
	<table class="table table-border table-bordered table-bg">
		<tbody>
			<tr class="text-c">
				<td width="150"><code>标题</code></td>
				<td><input type="text" value="{$info['title']}" id="title" name="title" class="input-text size-M radius"></td>
			</tr>
			<tr>
				<td class="text-c" width="150"><code>产品宣传</code></td>
				<td>
					<span class="select-box radius" style="width: 180px;">
						<select class="select" size="1" name="newstype" id="newstype">
							<option value="0" {$info['newtype'] == 0 ? 'selected' : ''}>否</option>
							<option value="1" {$info['newtype'] == 1 ? 'selected' : ''}>是</option>
						</select>
					</span>
				</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>宣传分店</code></td>
				<td>
					<span class="select-box radius" style="width: 180px;">
						<select class="select" size="1" name="shop_id" id="shop_id">
							<option value="0">--请选择--</option>
							<?php foreach($shoplist as $sp){ ?>
							<option value="{$sp['shop_id']}" {$info['shop_id'] == $sp['shop_id'] ? 'selected' : ''}>{$sp['title']}</option>
							<?php } ?>
						</select>
					</span>
				</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>文章地址</code></td>
				<td>http://mamagy.com/xj/index.php/mama/weixin/index/newid/{$info['newid']}.html</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>是否展示封面图</code></td>
				<td>
					<span class="select-box radius" style="width: 180px; ">
						<select class="select" size="1" name="isshow" id="isshow">
							<option value="0" {$info['isshow'] == 0 ? 'selected' : ''}>否</option>
							<option value="1" {$info['isshow'] == 1 ? 'selected' : ''}>是</option>
						</select>
					</span>
				</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>封面图</code></td>
				<td>
					<form action="" method="post" class="form form-horizontal" id="uploadform" enctype="multipart/form-data">
						<span class="btn-upload"> 
							<a href="javascript:void();" class="btn btn-primary radius uploadBtn">
								<i class="Hui-iconfont"></i> 浏览文件
							</a>
							<input type="file" multiple="" name="file[]" class="input-file" onchange="uploadImages();">
						</span>
					</form>
					<input type="hidden" name="images" id="images" value="{$info['images']}" />
					<div id="imgshow" style="display: <?php echo empty($info['images']) ? 'none' : 'block'; ?>;">
						<hr />
						<img src="__PUBLIC__/upload/{$info['images']}" style="width: 100px; height: 100px;"/>
					</div>
				</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>内容</code></td>
				<td>
					<!--文本编辑框-->
					<textarea id="elm1" name="elm1" class="xheditor" rows="26" cols="120" style="width: 100%">
						<?php echo html_entity_decode($info['desc']); ?>
					</textarea>
					<!--
					<textarea id="editor" type="text/plain" style="width:1024px;height:400px;"></textarea>-->
				</td>
			</tr>
			<tr>
				<td width="150" class="text-c"><code>排序</code></td>
				<td>
					<input type="text" value="{$info['sort']}" id="sort" name="sort" class="input-text size-M radius">
				</td>
			</tr>
			<tr>
				<td class="text-c" colspan="2">
					<a class="btn btn-primary radius submit" href="javascript:void(0);"><i class="Hui-iconfont">&#xe600;</i> 发布资讯</a>
				</td>
			</tr>
		</tbody>
	</table>
</div>
<script type="text/javascript">
$(document).ready(function(){
	/*
	var ue = UE.getEditor('editor', {
			allHtmlEnabled: false,//提交到后台的数据是否包含整个html字符串
			autoHeightEnabled: false,
			autoFloatEnabled: true,
			allowDivTransToP: false//阻止div标签自动转换为p标签
		});*/
		//ue.getAllHtml();
	//提交数据
	$(".submit").on('click', function(){
		var data = {};
		var title = $("#title").val() || "";
		if(title.length <= 0 || title.length > 200){
			layer.msg('标题长度在1~200个字符之间', {icon: 0, time: 2000});
			return;
		}else{
			data.title = title;
		}
		data.newtype = $("#newstype").val();
		data.shop_id = $("#shop_id").val();
		//获取封面图片
		data.images = $("#images").val();
		/*
		if(!ue.hasContents()){
			layer.msg('请先编辑内容', {icon: 0, time: 2000});
			return;
		}*/
		data.isshow = $("#isshow").val();
		//data.desc = ue.getContent();
		data.desc = $("#elm1").val();
		data.sort = $("#sort").val();
		//判断是否是编辑信息
		data.newid = "{$info['newid']}";
		//提交数据
		$.post('add.html', data, function(row){
			if(row/1 == 1){
				layer.msg('发布成功', {icon: 1, time: 2000});
			}else{
				layer.msg('发布失败', {icon: 1, time: 2000});
			}
		});
	});

});
</script>
</body>
</html>